package com.wind.plugin.configuration;

import com.wind.plugin.configuration.configUI.HighLightClassPanel;
import com.wind.plugin.configuration.configUI.HighLightFieldPanel;

import javax.swing.*;

/**
 * @author wind
 * @version 1.0
 * @description: TODO
 * @date 2025/2/15 16:01
 */
public class PluginSettingsComponent {
    private JPanel panel;
    private HighLightClassPanel classPanel;
    private HighLightFieldPanel fieldPanel;

    public PluginSettingsComponent() {
        panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        // Classes configuration
        classPanel = new HighLightClassPanel();
        fieldPanel = new HighLightFieldPanel();

        updateTableModel();

        panel.add(classPanel);
        panel.add(fieldPanel);
    }

    public JPanel getPanel() {
        return panel;
    }

    /**
     * @description:
     *
     * @return: void
     * @author wind
     * @date: 2025/2/16 23:01
     */
    private void updateTableModel() {
        PluginSettingsState settings = PluginSettingsState.getInstance();
        this.classPanel.setHighlightClasses(settings.getHighlightClasses());
        this.fieldPanel.setFieldList(settings.getCurrencyFields());
    }

    public HighLightClassPanel getClassPanel() {
        return classPanel;
    }

    public HighLightFieldPanel getFieldPanel() {
        return fieldPanel;
    }

}
